import { requestClient } from '#/api/request';

export namespace CheckRecordApi {
  export type Params = object;
  export interface GetCheckRecordReq {
    pageNum: number;
    pageSize: number;
  }

  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date | null;
    remark: string;
    params: Params;
    recordId: number;
    planId: null | number;
    planCode: null | string;
    planName: null | string;
    planType: null | string;
    machineryId: number;
    machineryCode: string;
    machineryName: string;
    machineryBrand: string;
    machinerySpec: string;
    checkTime: Date;
    userId: null | number;
    userName: null | string;
    nickName: null | string;
    status: string;
    attr1: null | string;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface GetCheckRecordListResp {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取类型列表
export const getCheckRecordList = (params: CheckRecordApi.GetCheckRecordReq) =>
  requestClient.get<CheckRecordApi.GetCheckRecordListResp>(
    '/mes/dv/checkrecord/list',
    {
      params,
    },
  );

// 修改保养项目设置
export const updateCheckRecord = (data: CheckRecordApi.Row) =>
  requestClient.put<CheckRecordApi.GetCheckRecordListResp>(
    '/mes/dv/checkrecord',
    data,
  );

// 增加保养项目设置
export const addCheckRecord = (data: CheckRecordApi.Row) =>
  requestClient.post<CheckRecordApi.GetCheckRecordListResp>(
    '/mes/dv/checkrecord',
    data,
  );

// 删除保养项目设置
export const deleteCheckRecord = (id: string) =>
  requestClient.delete<CheckRecordApi.GetCheckRecordListResp>(
    `/mes/dv/checkrecord/${id}`,
  );
